home *** CD-ROM | disk | FTP | other *** search
- #include "FractalTreeObject.cpp"
-
- #define kBaseResID 128
- #define kMoveToFront (WindowPtr)-1L
- #define kFontSize 9
- #define kSleep 1L
-
-
- // Globals
-
- Boolean gDone;
-
-
-
- // ****************************************************************
- // Prototypes
-
- void ToolBoxInit();
- void WindowInit();
- void MainLoop();
- void EventInit();
- void HandleMouseDown( EventRecord *event );
-
-
-
- // ****************************************************************
- // Main
-
- void main()
- {
- ToolBoxInit();
- WindowInit();
-
- MainLoop();
- }
-
-
-
- // ****************************************************************
- // ToolBoxInit
-
- void ToolBoxInit()
- {
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs( nil );
- InitCursor();
- }
-
-
-
- // ****************************************************************
- // WindowInit
-
- void WindowInit()
- {
- WindowPtr window;
- Rect windRect;
-
- window = GetNewWindow( kBaseResID, nil, kMoveToFront );
-
- if (window == nil)
- {
- SysBeep( 10 ); // couldn't load wind resource
-
- ExitToShell();
- }
-
- SetPort( window );
- TextSize( kFontSize );
-
- ShowWindow( window );
- }
-
-
-
- // ****************************************************************
- // EventInit
-
- void EventInit()
- {
- OSErr err;
- long result;
-
- err = Gestalt(gestaltAppleEventsAttr, &result);
- }
-
-
- // ****************************************************************
- // MainLoop
-
- void MainLoop()
- {
- EventRecord event;
- int drawDone = 0;
-
- FractalTree Tree1(14, 0.69, 3.1415926/8, 0.3, 0.9); // tested up to 17 at 20000 K
-
- gDone = false;
- while (gDone == false)
- {
- if (drawDone == 0)
- {
-
- Tree1.GrowTree();
- Tree1.DrawTree();
- drawDone = 1;
- }
-
- WaitNextEvent(everyEvent, &event, kSleep, NULL);
-
- switch ( event.what )
- {
- case mouseDown:
- HandleMouseDown( &event );
- break;
- }
- }
- }
-
-
-
- // ****************************************************************
- // HandleMouseDown
-
- void HandleMouseDown( EventRecord *event )
- {
- WindowPtr window;
- short windowPart;
-
- windowPart = FindWindow( event->where, &window );
-
- switch ( windowPart )
- {
- case inSysWindow:
- SystemClick( event, window );
- break;
- case inDrag:
- DragWindow( window, event->where, &(qd.screenBits.bounds) );
- break;
- case inGoAway:
- gDone = true;
- break;
- }
- }
-
-
-
-